---
title: Cerebras OpenAI
description: Learn how to use Cerebras OpenAI with Agno.
---

## OpenAI-Compatible Integration

Cerebras can also be used via an OpenAI-compatible interface, making it easy to integrate with tools and libraries that expect the OpenAI API.

### Using the OpenAI-Compatible Class

The `CerebrasOpenAI` class provides an OpenAI-style interface for Cerebras models:

First, install openai:

```shell
pip install openai
```

```python
from agno.agent import Agent
from agno.models.cerebras import CerebrasOpenAI

agent = Agent(
    model=CerebrasOpenAI(
        id="llama-4-scout-17b-16e-instruct",  # Model ID to use
        # base_url="https://api.cerebras.ai", # Optional: default endpoint for Cerebras
    ),
    markdown=True,
)

# Print the response in the terminal
agent.print_response("write a two sentence horror story")
```

### Configuration Options

The `CerebrasOpenAI` class accepts the following parameters:

| Parameter  | Type | Description                                                   | Default                   |
| ---------- | ---- | ------------------------------------------------------------- | ------------------------- |
| `id`       | str  | Model identifier (e.g., "llama-4-scout-17b-16e-instruct")     | **Required**              |
| `name`     | str  | Display name for the model                                    | "Cerebras"                |
| `provider` | str  | Provider name                                                 | "Cerebras"                |
| `api_key`  | str  | API key (falls back to CEREBRAS_API_KEY environment variable) | None                      |
| `base_url` | str  | URL of the Cerebras OpenAI-compatible endpoint                | "https://api.cerebras.ai" |

`CerebrasOpenAI` also supports the parameters of [OpenAI](/reference/models/openai).

### Examples

- View more examples [here](/examples/models/cerebras_openai/basic).
